package com.kuang.controller;

import com.kuang.entity.Achievement;
import com.kuang.entity.AchievementType;
import com.kuang.service.AchievementService;
import com.kuang.service.AchievementTypeService;
import com.kuang.service.Impl.AchievementTypeServiceImpl;
import com.kuang.service.StudentInfoService;
import com.kuang.util.ResultModel;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/student")
public class StudentController {

    @Resource
    private StudentInfoService studentInfoService;
    @Resource
    private AchievementService achievementService;

    @Resource // Spring框架中用于依赖注入的注解，用于自动装配Bean
    private AchievementTypeServiceImpl achievementTypeServiceImpl;

    @Resource
    private AchievementTypeService achievementTypeService;

    @GetMapping("/hello")
    public ResultModel<String> hello() {
        return ResultModel.success("你好,学生角色");
    }


    /**
     * 成果类别表接口
     * */
     // 查看类别表所有数据(包含逻辑删除的)
    @GetMapping("/achievementType")
    public ResultModel<AchievementType> getAchievementTypeAll(){
        List<AchievementType> achievementTypeAll = achievementTypeServiceImpl.getAchievementTypeAll();
        return ResultModel.success(achievementTypeAll);
    }

    // 查看类别表所有数据（不包含逻辑删除的）
    @GetMapping("/achievementTypeAll")
    public ResultModel<AchievementType> achievementTypeAll(){
        List<AchievementType> list = achievementTypeService.findAchievementTypeAll();
        return ResultModel.success(list);
    }
    /**
     * 申请接口(成果表新增)
     * */
    @PostMapping("/application")
    public ResultModel<Achievement> addAchievementId(@RequestBody Achievement achievement) {
        achievementService.addAchievement(achievement);
        return ResultModel.success();
    }

    /**
     * 修改成果表接口
     * */
    @PutMapping("modify")
    public ResultModel<Achievement> modifyAchievement(@RequestBody Achievement achievement){
        int row = achievementService.modifyAchievementById(achievement);
        return ResultModel.success();
    }



    /**
     * 学习成果认定 查询
     */

    // 成果认定查询（根据类别，学号查询）
    @GetMapping("/identified")
    public ResultModel<Achievement> findAchievementByType(@RequestParam("s_number") String s_number, @RequestParam("status") int status){
        List<Achievement> list = achievementService.findAchievementByType(s_number,status);
        return ResultModel.success(list);
    }



     // 学习成果积累信息（详细 根据类别，学号查询）
    @GetMapping("/achievement")
    public ResultModel<Achievement> gitAchievementByType(@RequestParam("s_number") String s_number, @RequestParam("status") int status) {
        List<Achievement> list = achievementService.findAchievementByType(s_number,status);
        return ResultModel.success(list);
    }


    /**
     * 学习成果转换
     * */

    //成果转换查询（根据类别，学号查询）
    @GetMapping("/convert")
    public ResultModel<Achievement> getAchievementId(@RequestParam("s_number") String s_number, @RequestParam("status") int status) {
        List<Achievement> list = achievementService.getAchievementId(s_number,status);
        return ResultModel.success(list);
    }


    // 查看成果转换历史明细
    @GetMapping("/history")
    public ResultModel<Achievement> getHistoryId(@RequestParam("s_number") String s_number, @RequestParam("status") int status) {
        List<Achievement> list = achievementService.getAchievementId(s_number,status);
        return ResultModel.success(list);
    }
}
